package com.example.dbcms.controller.admin;

import com.example.dbcms.annotation.Log;
import com.example.dbcms.domain.CostStatistic;
import com.example.dbcms.service.ParkingFeeService;
import com.example.dbcms.service.PropertyFeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/admin/sys")
@Api("费用统计路由")
public class CostStatisticController {

    @Autowired
    private PropertyFeeService propertyFeeService;

    @Autowired
    private ParkingFeeService parkingFeeService;

    /**
     * 跳转到费用统计主页面
     * @return
     */
    @GetMapping("/costStatistic")
    @ApiOperation("跳转到费用统计主页面")
    @Log(type="跳转到费用统计主页面")
    public String index(CostStatistic costStatistic, ModelMap modelMap) throws InterruptedException {
        System.out.println(Thread.currentThread().getName());
        Thread.sleep(2000);
        //System.out.println(costStatistic);
        CostStatistic allPropertyFee = propertyFeeService.getAllPropertyFee(costStatistic);
        CostStatistic allParkingFee = parkingFeeService.getAllParkingFee(costStatistic);
        allPropertyFee.setStartDate(costStatistic.getStartDate());
        allPropertyFee.setEndDate(costStatistic.getEndDate());
        allPropertyFee.setBuildingNo(costStatistic.getBuildingNo());
        allPropertyFee.setRoomNo(costStatistic.getRoomNo());
        allPropertyFee.setParkingFeeSum(allParkingFee.getParkingFeeSum());
        allPropertyFee.setParkingFeedSum(allParkingFee.getParkingFeedSum());
        allPropertyFee.setParkingNotFeedSum(allParkingFee.getParkingNotFeedSum());
        modelMap.put("costStatistic",allPropertyFee);
        return "admin/costStatistic/index";
    }
}
